home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / TPTC17GS.LZH / TPTC.TXT < prev    next >
Text File  |  1988-04-22  |  30KB  |  905 lines

  1.  
  2.  
  3. .c TPTC17 - Translate Pascal to C
  4.  
  5. .c Version 1.7a, 31-Mar-88
  6.  
  7.  
  8. .c (C) Copyright 1986, 1988 by Samuel H. Smith
  9.  
  10. .c All rights reserved.
  11.  
  12.  
  13.  
  14.     This program will read a turbo pascal source file and convert it
  15.     into the corresponding C source code.   It does much of the work
  16.     required in a full translation.
  17.  
  18. .f Turbo Pascal is a registered trademark of Borland International.
  19.  
  20.  
  21.  
  22. .v TABLE OF CONTENTS
  23.  
  24.     Usage . . . . . . . . . . . . . . . . . . . . . . .
  25.  
  26.     Command line options. . . . . . . . . . . . . . . .
  27.  
  28.     Translations performed. . . . . . . . . . . . . . .
  29.  
  30.     Support for Turbo Pascal 4.0. . . . . . . . . . . .
  31.        Files created for each unit. . . . . . . . . . .
  32.        The system unit. . . . . . . . . . . . . . . . .
  33.        The standard units . . . . . . . . . . . . . . .
  34.        Interrupt and Inline procedures. . . . . . . . .
  35.  
  36.     Support for Turbo Pascal 3.0. . . . . . . . . . . .
  37.  
  38.     Support for Pascal/MT+. . . . . . . . . . . . . . .
  39.  
  40.     Language extensions . . . . . . . . . . . . . . . .
  41.        Imbedded C language. . . . . . . . . . . . . . .
  42.        Imbedded preprocessor directives . . . . . . . .
  43.        The 'AS <replacement name>' clause . . . . . . .
  44.        The 'SYMTYPE <typename>' clause. . . . . . . . .
  45.  
  46.     Known problems and planned changes. . . . . . . . .
  47.  
  48.     Explanation of error messages . . . . . . . . . . .
  49.  
  50.     Explanation of errors reported by the C compiler. .
  51.  
  52.     Revision history. . . . . . . . . . . . . . . . . .
  53.  
  54.     Support . . . . . . . . . . . . . . . . . . . . . .
  55.  
  56.     License . . . . . . . . . . . . . . . . . . . . . .
  57.        SourceWare: What is it?. . . . . . . . . . . . .
  58.        Why SourceWare?. . . . . . . . . . . . . . . . .
  59.        Copyright. . . . . . . . . . . . . . . . . . . .
  60.  
  61. .p a
  62. .v USAGE
  63.  
  64.    TPTC input_file [output_file] [options]
  65.  
  66.  
  67. Where:
  68.    input_file      specifies the main source file, .PAS default
  69.    output_file     specifies the output file, .C default
  70.    -B              deBug trace during scan
  71.    -BP             deBug trace during Parse
  72.    -D              Dump user symbols
  73.    -DP             Dump Predefined system symbols
  74.    -I              output Include files' contents
  75.    -L (-NL)        map (don't map) all identifiers to Lower case
  76.    -M              use Pascal/MT+ specific translations
  77.    -NC             No Comments passed to output file
  78.    -NU             No standard Unit (use to translate tptcsys)
  79.    -Q              Quiet mode; suppress warnings
  80.    -R              format displays for Redirection
  81.    -Sdir\          search dir\ for .UNS symbol files
  82.    -Tnn            Tab nn columns in declarations
  83.    -Wdrive:        use drive: for Work/scratch files (ramdrive)
  84.    -#              don't translate lines starting with "#"
  85.  
  86.  
  87. Default command parameters are loaded from TPTC environment variable.
  88.  
  89.  
  90. Examples:
  91.    tptc fmap
  92.    tptc fmap -L -d -wj:\tmp\
  93.    tptc -l -d -wj: -i -q -t15 fmap.pas fmap.out
  94.  
  95.    set tptc=-wj: -i -l -sc:\libs
  96.    tptc test       ;uses options specified earlier
  97.  
  98. .p a
  99. .v COMMAND LINE OPTIONS
  100.  
  101. .u -B
  102.  
  103. Debug trace during scan.  Traces source line numbers and lexical tokens
  104. seen during the source scan.  This trace may be helpful to isolate the
  105. exact context where an error message is produced.  It is also helpful in
  106. tracking down "lockups" during translation (although the current
  107. translator version should be immune to locking).
  108.  
  109. Example:
  110.    TYPES.PAS(26) {str2} {:=} {"hello2"} {;}
  111.    TYPES.PAS(27) {str1} {[} {1} {]} {:=} {'H'} {;}
  112.  
  113.  
  114. .u -BP
  115.  
  116. Debug trace during parse.  This option produces a trace of each major
  117. step in the parsing process.  This trace is handy if you want to know
  118. how the translator recognizes a particular statement.  When the
  119. translator botches a translation, this output will also help to identify
  120. the point at which the mistake was made.
  121.  
  122. Example:
  123.    TYPES.PAS(26) {str2} <stmt> <ident> <lvalue> {:=} <assign> {"hello2"}
  124.    <expr> <term> <string> {;}
  125.    TYPES.PAS(27) {str1} <stmt> <ident> <lvalue> {[} <subs> {1} <expr>
  126.    <term> <number> {]} {:=} <assign> {'H'} <expr> <term> <char> {;}
  127.  
  128.  
  129.  
  130. .u -D
  131.  
  132. Dump user symbols.  Produces a report of the symbol table contents after
  133. each program unit is processed.  This report is handy if you suspect the
  134. translator has min-interpreted a declaration.  It is also instructive in
  135. following a given translation.
  136.  
  137. Example:
  138.    /* User symbols:
  139.     *    Type                 Class  Base  Limit Pars  Pvar   Identifier
  140.     *   -------------------- ------- ---- ------ ---- ------ --------------
  141.     *    integer             []       100      0   -1      0   ar3
  142.     *    myarray             Scalar     1      0   -1      0   ar2
  143.     *    integer             Subtype  100    200   -1      0   range2
  144.     *    integer             Const      0    100   -1      0   lowend
  145.     */
  146.  
  147.  
  148.  
  149. .u -DP
  150.  
  151. Dump predefined system symbols.  Reports the "predefined" symbols at the
  152. end of a translation.  This portion of the symbol table includes the
  153. symbols from any "uses" statements, as well as the "builtin" symbol
  154. table entries.
  155.  
  156. Example:
  157.    /* Predefined symbols:
  158.     *    Type                 Class  Base  Limit Pars  Pvar   Identifier
  159.     *   -------------------- ------- ---- ------ ---- ------ --------------
  160.     *    text                Scalar     0      0   -1      0   input
  161.     *    integer             Subtype    0      0   -1      0   shortint
  162.     *    integer             Builtin    0      0    2      0   memw
  163.     *    string              *          1      0   -1      0   charptr
  164.     *    char                []         1      0   -1      0   string
  165.     *    boolean             ()         0      0    1      0   seekeof
  166.     *    Int                            0  32767   -1      0   integer
  167.     */
  168.  
  169.  
  170.  
  171. .u -I
  172.  
  173. Output include files' contents.  This option causes the translator to
  174. process all include files during translation.  The include file contents
  175. will then be included in the translation output.  Use the UNINC
  176. post-processor to extract the translated include files back to separate
  177. files.
  178.  
  179. When not used, include statements are translated into C format #include
  180. directives, but the contents of the include file are not loaded.
  181. Improper translation is likely to result if the include file contains
  182. procedure or data declarations needed during the translation of the main
  183. file.
  184.  
  185.  
  186.  
  187. .u -L (-NL)
  188.  
  189. Map (don't map) all identifiers to lower case.   The -L option causes
  190. the translator to force all identifiers to lower case.  This is useful
  191. when translating sources that are all upper-case, or that mix cases in
  192. an irregular way.  This may be required since case is significant to all
  193. standard C compilers.   When compiling a unit, the unit symbol file will
  194. contain lower-case identifiers.   Identifiers loaded from a "uses"
  195. statement are not effected by this option (they are effected by the -L
  196. option at the time of translation of the unit interface).   -NL cancels
  197. the effect of -L and is provided as an "over-ride" when you have made -L
  198. the default through the TPTC environment variable.
  199.  
  200.  
  201. .u -M
  202.  
  203. Use Pascal/MT+ specific translations.  Enables some translations that
  204. are specific to Pascal/MT+.  This mode is automatically activated when a
  205. "MODULE" statement is encountered.
  206.  
  207.  
  208. .u -NC
  209.  
  210. No comments passed to output file.  This option strips comments from the
  211. translated code.  It is useful when translating very large programs,
  212. since it greatly reduces the size of the translated output.
  213.  
  214.  
  215. .u -NU
  216.  
  217. No standard unit.  This option disables the implicit use of TPTCSYS. It
  218. is used primarily when re-translating TPTCSYS (since it should not use
  219. itsself!).  It can also be used where you plan to explicity use your own
  220. special system unit.
  221.  
  222.  
  223. .u -Q
  224.  
  225. Quiet mode; suppress warnings.  This option suppresses all "Warning:"
  226. messages that are produced by the translator.  Warning messages are
  227. often very important, so be careful with this option.
  228.  
  229.  
  230. .u -R
  231.  
  232. Format displays for redirection.  This option disables the running
  233. line-number and include filename display that is normally produced. It
  234. is needed when you redirect translator output to a file.
  235.  
  236.  
  237. .u -Sdir\
  238.  
  239. Search dir\ for .UNS symbol files.  Each "uses" statement causes a
  240. corresponding .UNS file to be loaded.  This option specifies the
  241. directory in which your standard .UNS files are stored.  The translator
  242. first checks the current directory, then the specified search directory.
  243. This option eliminates the need for a copy of TPTCSYS.UNS, DOS.UNS,
  244. CRT.UNS, etc. in each directory.
  245.  
  246.  
  247. .u -Tnn
  248.  
  249. Tab nn columns in declarations.  The translator attempts to align
  250. identifiers in declarations.  Because of the differences in identifier
  251. ordering between C and pascal, it is not possible to preserve the
  252. original spacing from the source file.  If you specify -T0, all
  253. alignment will be disabled.  Remember, this is a translator - not a
  254. pretty-printer.  If you want "beautiful" formatting in the translated
  255. program, you will need to use a formatting utility.  I recommend
  256. INDENT2, which is very flexible and includes full source C code.
  257.  
  258.  
  259. .u -Wdrive:
  260.  
  261. Use drive: for work/scratch files (ramdrive).  The translator creates a
  262. scratch file for each procedure translated.  This option allows you to
  263. route those scratch files to a specified disk drive or subdirectory.  If
  264. you have a RAMDISK, you will want to use the -W option.
  265.  
  266.  
  267. .u -#
  268.  
  269. Don't translate lines starting with "#".  Programs originally written
  270. for TSHELL already include C compatible preprocessor directives. This
  271. option allows the translator to pass these directives without any
  272. translation.
  273.  
  274. .p a
  275. .v TRANSLATIONS PERFORMED
  276.  
  277. Comments are translated from either {...} or (*...*) into /*...*/.
  278.  
  279. Begin and End are translated into { and }.
  280.  
  281. Const declarations are translated from
  282.    ID = VALUE
  283. into
  284.    static ID = VALUE.
  285.  
  286. Simple Var declarations are translated from
  287.    ID TYPE
  288. into
  289.    TYPE ID.
  290.  
  291. Integer subrange types are translated into integers.
  292.  
  293. Record types are translated from
  294.    ID = record MEMBER-LIST end
  295. into
  296.    typedef struct { MEMBER-LIST } ID.
  297.  
  298. Enumeration types are translated from
  299.    ID = (...)
  300. into
  301.    typedef enum {...} ID.
  302.  
  303. Array types are translated from
  304.    ID = array [RANGE] of TYPE
  305. into
  306.    typedef TYPE ID[RANGE].
  307.  
  308. Pointer types are translated from
  309.    ID = ^DEFINED-TYPE
  310. into
  311.    DEFINED-TYPE *ID.
  312.  
  313. String types are translated from
  314.    ID = string[N]
  315. into
  316.    typedef char ID[N+1].
  317.  
  318. File types are translated from
  319.    ID = text[N]
  320.    ID = file
  321. into
  322.    FILE *ID
  323.    int ID.
  324.  
  325. For statements are translated from
  326.    for VAR := FIRST to LAST do STATEMENT
  327.    for VAR := FIRST downto LAST do statement
  328. into
  329.    for (VAR = FIRST; VAR <= LAST; VAR++) STATEMENT
  330.    for (VAR = FIRST; VAR >= LAST; VAR--) STATEMENT
  331.  
  332. While statements are translated from
  333.    while COND do STATEMENT
  334. into
  335.    while (COND) statement.
  336.  
  337. Repeat statements are translated from
  338.    repeat STATEMENTS until COND
  339. into
  340.    do { STATEMENTS } while(!COND).
  341.  
  342. If statements are translated from
  343.    if COND then STATEMENT else STATEMENT
  344. into
  345.    if (COND) STATEMENT; else STATEMENT.
  346.  
  347. Case statements are translated from
  348.    case VALUE of
  349.       V:    STATEMENT;
  350.       V,U:  STATEMENT;
  351.       else  STATEMENT
  352.    end
  353. into
  354.    switch (VALUE) {
  355.       case V:  STATEMENT; break;
  356.       case V:
  357.       case U:  STATEMENT; break;
  358.       default: STATEMENT;
  359.    }.
  360.  
  361. Ranges in the form VAL..VAL automatically include cases for intermediate
  362. values.
  363.  
  364. The IN operator is translated from
  365.    VAL in [A,B,C]
  366.  into
  367.    inset(VAL, setof(A,B,C,-1)).
  368.  
  369. The ParamCount and ParamStr functions are translated from
  370.    paramcount
  371.    paramstr(n)
  372. into
  373.    argc
  374.    argv[n].
  375.  
  376. Dummy parameter lists are added to function and procedure calls, where
  377. they are required in C but not in Pascal.
  378.  
  379. The following expression operators are translated
  380.    from  DIV  to  / ,     MOD  to  % ,
  381.          AND  to  &&,     OR   to  ||,
  382.          XOR  to  ~ ,     <>   to  !=,
  383.          NOT  to  ! ,     SHR  to  >>,
  384.          SHL  to  <<,     =    to  ==,               {+others}
  385.          :=   to  = .
  386. Bitwise AND and OR operators are translated into & and |.
  387.  
  388. The '^' symbol is translated
  389.    from  VAR^          to  *VAR,
  390.          VAR^.MEMBER   to  VAR->MEMBER.
  391.  
  392. Exit statements are translated
  393.    from  exit    to  return.
  394.  
  395. The New operator is translated from
  396.    new(VAR)
  397. into
  398.    VAR = malloc(sizeof(*VAR)).
  399.  
  400.  
  401. Procedure/function formal parameter lists are translated into the
  402.    new form defined in ANSI C (and as used by Turbo C):
  403. from
  404.    function NAME(V1: TYPE1; V2: TYPE2): TYPE3
  405. into
  406.    TYPE3 NAME(TYPE1 V1,TYPE2 V2)
  407.  
  408. Procedures are translated into functions with 'void' return types.
  409.  
  410. The special character literal syntax, ^C or #nn, is translated into
  411. '\xHH', where HH is the hex notation for the ascii code.
  412.  
  413. Hex constants $hhhh are translated into 0xhhhh.
  414.  
  415. Write and WriteLn are translated from:
  416.    write(VAR,VAR:n,VAR:n:m)
  417.    writeln(FILE,VAR,VAR,VAR)
  418. into
  419.    printf("%d%nd%n.md",VAR,VAR,VAR)
  420.    fprintf(FILE,"%d%d%d\n",VAR,VAR,VAR).
  421.  
  422. Read and ReadLn are translated from:
  423.    read(VAR,VAR,VAR)
  424.    readln(FILE,VAR,VAR,VAR)
  425. into
  426.    scanf("%d%nd%d",&VAR,&VAR,&VAR)
  427.    fscanf(FILE,"%d%d%d\n",&VAR,&VAR,&VAR).
  428.  
  429. String assignments are translated from:
  430.    VAR := "string"
  431.    VAR := "string1(" + VAR1 + ")string2"
  432. into
  433.    strcpy(VAR, "string")
  434.    sbld(VAR,"string1(%s)string2",VAR1).      {+other compound forms}
  435.  
  436. String comparisons are translated from:
  437.    VAR == "string"
  438.    VAR < "string"
  439.    "string" >= VAR
  440. into
  441.    (strcmp(VAR,"string") == 0)
  442.    (strcmp(VAR,"string") < 0)
  443.    (strcmp("string",VAR) >= 0).
  444.  
  445. Function value assignments are translated from:
  446.    FUN_NAME := expr
  447. into
  448.    return expr.
  449.  
  450. Numeric statement labels are translated to label_nn.
  451. Label identifiers are not changed.
  452. Local GOTO statements are handled properly.
  453.  
  454. Nested procedures are "flattened" out, but local variable sharing and
  455. local scoping are not translated.
  456.  
  457. Direct I/O port and memory references are translated:
  458.    portw[expr] := expr + port[n]
  459.    mem[seg:ofs] := memw[seg:ofs] + expr
  460. into
  461.    outport(expr, expr+inportb(n))
  462.    pokeb(seg,ofs, peek(seg,ofs)+expr)
  463.  
  464. VAR parameters are translated into pointer variables;  references to
  465. formal parameters are implicitly dereferenced (i.e. * added); references
  466. to actual parameters are implicitly referenced (i.e. & added).
  467.  
  468. Forward pointer type declarations are translated, but will not
  469. compile in C.  They must be manually recoded.
  470.  
  471. Variant record type declarations are translated into unions.
  472.  
  473. Absolute variables are translated into initialized pointer variables.
  474.  
  475. The WITH statement is translated into an initialized pointer variable.
  476. Expressions depending on the with are translated.  There is still some
  477. ambiguity when translating nested with statements.
  478.  
  479. Variant record type decl's are translated into unions.  Expressions
  480. using the variant part are translated when there is no ambiguity.
  481.  
  482. .p a
  483. .v SUPPORT FOR TURBO PASCAL 4.0
  484.  
  485. .u Units
  486.  
  487. The translator will create several files for each UNIT that is
  488. translated:
  489.  
  490. file.UNS
  491.    Unit symbol table.  This table is loaded during translation of
  492.    programs or units that "use" this unit.
  493.  
  494. file.UNH
  495.    Unit header file.  This is a C "header" that defines all entry points
  496.    and data types declared in the unit interface section.  An "include"
  497.    statement is automatically generated in programs or units that "use"
  498.    this unit.
  499.  
  500. file.C
  501.    This is the body of the unit.  It will also include the unit header
  502.    file.  A special #define is generated to nullify the effect of the
  503.    "extern" prefix in all unit header declarations.  This will cause the
  504.    C compiler to perform the actual allocation of data objects within
  505.    this compilation unit.
  506.  
  507.  
  508. .u The system unit
  509.  
  510. The translator automatically uses its own "system" unit at the start of
  511. each translation.  The source for this unit is TPTCSYS.PAS.  The
  512. declarations in this unit allow the translator to generate proper
  513. parameter passing for predefined procedures that are part of Borland's
  514. system unit.
  515.  
  516. Several language extension have been implemented to simplify the
  517. creation of C language runtime libraries based on Turbo Pascal units.
  518. See the language extensions section for details.
  519.  
  520.  
  521.  
  522. .u The standard units
  523.  
  524. Borland includes the interface section for each standard unit as a .DOC
  525. file.  These are suitable for direct "translation" after you make the
  526. noted changes.  You need to "translate" these files to generate the unit
  527. header and unit symbol table files that are required later.
  528.  
  529. The GRAPH.DOC unit will require manual edits before it can be
  530. translated.  It seems that some commentary documentation was added that
  531. does not conform to turbo pascal syntax.  These comment blocks should be
  532. deleted from the file (or enclosed in proper comment delimiters).   The
  533. long documentation section following the "implementation" keyword will
  534. be ignored if you place a single period on the following line.
  535.  
  536.  
  537. .u Interrupt and Inline procedures
  538.  
  539. These are both translated, but will probably need recoding to be
  540. compatible with C compilers.  A warning is generated if either of these
  541. procedure types is detected.
  542.  
  543. .p a
  544. .v SUPPORT FOR TURBO PASCAL 3.0
  545.  
  546. The standard unit, tptcsys, contains only declarations that are implicit
  547. in Turbo Pascal 4.0 compilations.  Several declarations needed by Turbo
  548. Pascal 3.0 are provided in the TP3 unit.  Add the line:
  549.  
  550.      uses TP3;
  551.  
  552. to the head of any Turbo Pascal 3.0 sources before attempting to
  553. translate them.
  554.  
  555. Note that many of the "missing" Turbo Pascal 3.0 declarations are
  556. actually provided by other Turbo Pascal 4.0 units (such as DOS and CRT).
  557.  
  558. .p a
  559. .v SUPPORT FOR PASCAL/MT+
  560.  
  561. Var declarations are translated from
  562.    ID external TYPE
  563. into
  564.    extern TYPE ID.
  565.  
  566. The following expression operators are translated
  567.    from   !   to  | ,    |    to   |,
  568.           &   to  & ,    ~    to   !,
  569.           ?   to  ! ,    \    to   !.
  570.  
  571. External function declarations are translated
  572. from
  573.    external function NAME(V1: TYPE1; V2: TYPE2): TYPE3
  574.    external [n] function NAME(V1: TYPE1; V2: TYPE2): TYPE3
  575. into
  576.    extern TYPE3 NAME()
  577.  
  578. External procedure declarations are translated
  579. from
  580.    external procedure NAME(V1: TYPE1; V2: TYPE2)
  581.    external [n] procedure NAME(V1: TYPE1; V2: TYPE2)
  582. into
  583.    extern void NAME()
  584.  
  585. Write and WriteLn are translated from:
  586.    write([ADDR(FUN)],VAR:n,VAR:n:m)
  587.    write([],VAR:n,VAR:n:m)
  588. into
  589.    iprintf(FUN,"%nd%n.md",VAR,VAR)
  590.    printf("%nd%n.md",VAR,VAR)
  591.  
  592. Read and ReadLn are translated from:
  593.    read([ADDR(FUN)],VAR,VAR)
  594.    read([],VAR,VAR)
  595. into
  596.    iscanf(FUN,"%d%nd%d",&VAR,&VAR,&VAR)
  597.    scanf("%d%nd%d",&VAR,&VAR,&VAR)
  598.  
  599. Long integer constants #nnn are translated into nnnL.
  600.  
  601.  
  602. .p a
  603. .v LANGUAGE EXTENSIONS
  604.  
  605. Several language extension have been implemented to simplify the
  606. creation of C language runtime libraries based on Turbo Pascal units.
  607. See the system unit, tptcsys.pas, for examples of these extensions.
  608.  
  609.  
  610. .u Imbedded C language
  611.  
  612. Lines starting with "\" are passed directly to the object file without
  613. any translation.  This allows you to imbed C language statements and
  614. declarations in your Pascal source file.  This is used in the
  615. implementation of many of the standard procedures.
  616.  
  617.  
  618. .u Imbedded preprocessor directives
  619.  
  620. Lines starting with '#' can be passed directly to the object file
  621. without any further processing.  This is useful when translating Pascal
  622. sources that already contain C preprocessor directives (as with TSHELL).
  623. You must use the "-#" command line option to enable this feature.
  624.  
  625.  
  626. .u The 'AS <replacement name>' clause
  627.  
  628. If a procedure declaration is followed with "as newname", the new
  629. identifier newname will be used in place of the original identifier in
  630. the object file.  This can be used to resolve conflicts between pascal
  631. procedures and standard C library procedures.  Example:
  632.  
  633.      procedure length(s: string): integer as strlen;
  634.  
  635.  
  636. .u The 'SYMTYPE <typename>' clause
  637.  
  638. If a variable declaration is followed with "symtype typename", the
  639. variable's symbol type in the symbol table will be changed to the
  640. specified symtype.   Example:
  641.  
  642.      type
  643.         text = record
  644.              ...
  645.         end SYMTYPE TEXT;
  646.  
  647. Legal typenames:
  648.      ARRAY           POINTER         FUNCTION        STRUCT
  649.      CONSTANT        SUBTYPE         SCALAR          BUILTIN
  650.      INT             LONG            DOUBLE          CHAR
  651.      FILE            TEXT            BOOLEAN         VOID
  652.      UNIT
  653.  
  654.  
  655. .p a
  656. .v KNOWN PROBLEMS AND PLANNED CHANGES
  657.  
  658. -- C operator precedence differs from that of Pascal, and the
  659.    differences are not translated.
  660.  
  661. -- Unit interface identifiers should be prefixed with unit name to
  662.    prevent conflicts with other identical identifiers in another unit.
  663.  
  664. -- Translate "dot notation" in reference to unit interface sections.
  665.  
  666. -- Allow overloading of record member identifiers (currently entered as
  667.    globals in the symbol table, leading to redeclarations if they are
  668.    used in different global contexts).
  669.  
  670. -- Nested procedure variable passing.
  671.  
  672. -- Set operations (general operator overloading? - using techniques
  673.    developed in earlier ada-tp project).
  674.  
  675. -- Selection of proper 'with' pointer when two are more with levels are
  676.    active (may result from symbol table changes when record member
  677.    identifiers get proper scope rules).
  678.    
  679. -- Return statement ordering in functions.
  680.  
  681. -- More runtime library functions.
  682.  
  683. -- Translations for binary (untyped, record types) file operations.
  684.  
  685. -- Detect and translate concat() calls.
  686.  
  687. -- Detect array-of-character data and use string-like translations.
  688.  
  689. -- Update documentation to match current program changes.
  690.  
  691. -- Write a translation guide, giving hints and tips for translating.
  692.  
  693. -- Detect and escape "%" in string expressions passed to scat, sbld,
  694.    etc.
  695.  
  696. -- Work on plvalue to reduce code duplication in initial identifier
  697.    parse.
  698.  
  699. -- com1..com2 range evaluates to 1 in subscript declaration (eg. wxterm)
  700.  
  701. .p a
  702. .v EXPLANATION OF ERROR MESSAGES
  703.  
  704. Fatal: Aborted by <escape> key
  705.    This message indicates that the user pressed the ESCAPE key to  abort
  706.    the translation in progress.
  707.         
  708. Fatal: Can't create tempfile: <NAME>
  709.    The translator wanted to create a temporary file but could not. This
  710.    is usually caused by an invalid drive or directory  specified with
  711.    the '-w' command line option.  It could also be  caused by
  712.    insufficient disk space, not enough file handles  available, or
  713.    excessive procedure block nesting.
  714.         
  715. Fatal: Can't open unit symbol file: <NAME>
  716.    The translator needed to load a unit symbol file (a .UNS file),  but
  717.    could not locate the file.  Tptc needs to load TPTCSYS.UNS  for each
  718.    translation (this file defines the default environment  and
  719.    predefined functions).  This could also be caused by a  missing or
  720.    incorrect directory specification in the '-s' command  line option.
  721.         
  722. Fatal: Functions nested too deeply
  723.    Procedure or function units were nested more than 10 levels  deeply. 
  724.    This might also be caused by a missing "interface"  keyword (which
  725.    would cause the procedure specifications to look  like nested
  726.    procedure implementations).
  727.         
  728. Fatal: Includes nested too deeply
  729.    Include files may be nested up to two levels.  
  730.         
  731. Fatal: Incompatible .UNS format
  732.    The unit symbol file loaded by a "uses" statement was bade by an
  733.    incompatible version of the translator.  Retranslate the used unit to
  734.    generate a new .UNS file.
  735.  
  736. Fatal: Out of memory
  737.    There was not enough memory to make another symbol table entry,  or
  738.    to allocate the buffer for a new file.  Increase memory, divide your
  739.    program into smaller parts, or include fewer units  in your "uses"
  740.    statement.
  741.  
  742. Fatal: Out of stack space 
  743.    This error indicates that all available stack was exhausted  while
  744.    parsing your source file.  It can be caused by highly  complex
  745.    expressions in conjunction with high levels of procedure  unit
  746.    nesting.
  747.  
  748. Fatal: Too many identifiers 
  749.    You listed too many identifiers in a declaration before the data type
  750.    specification.  These identifiers are limited because they must be
  751.    held until the ': type' clause is reached.  Break up the declaration
  752.    into two or more parts.
  753.  
  754. Fatal: Too many params
  755.    There were too many parameters in the current procedure declaration
  756.    or call.  This is currently limited to 16.
  757.  
  758. Error: Identifier expected
  759.    In an expression, a symbol or keyboard was found where an identifier
  760.    (variable name) was required.
  761.  
  762. Error: Section header expected
  763.    The translator was expecting VAR, CONST, TYPE, PROCEDURE,  FUNCTION,
  764.    or some other main section header.  Instead, it found  an identifier
  765.    or special character.  Often caused by faulty  recovery from a
  766.    previous error.
  767.  
  768. Warning: Dynamic length reference
  769.    A reference to the zero-th byte in a string was detected.  Since
  770.    translated code uses the C convention for strings, this code requires
  771.    a conversion to C string conventions.  The translator can handle all
  772.    of turbo's standard string operations.  Use length(str) rather than
  773.    ord(str[0]) for the string length.  Use str := copy(str,1,len) rather
  774.    than str[0] := chr(len) to modify the length of a string.
  775.         
  776. Warning: Expression too long
  777.    Expressions are limited to a maximum of 255 characters each.  This
  778.    limit applies to the combined lengths of all parameters in function
  779.    calls.  Simplify the expression, reduce use of 'with' statements, or
  780.    introduce intermediate variables.
  781.  
  782. Warning: Gigantic case range
  783.    A numeric range in a case selector covers too great a range.   Since
  784.    the translator must generate one line of code for each value  within
  785.    the range, it is advised that the statement be recoded  using an if
  786.    else if sequence.
  787.         
  788. Warning: Inline procedure
  789.    An inline procedure was detected within an interface section.
  790.    Interface sections must not contain executable code in the C language
  791.    target files.  Convert this to a normal procedure containing an
  792.    inline statement.
  793.         
  794. Warning: Interrupt handler
  795.    An 'interrupt' procedure was detected.  These procedures require
  796.    special attention, since the C conventions for interrupt  handlers
  797.    differ from those of turbo pascal.
  798.         
  799. Warning: Nested function
  800.    This warning is generated when a nested procedure/function block  is
  801.    found.  The translator does not yet translate shared  variables or
  802.    formal parameters among nested functions.
  803.  
  804. Warning: Redeclaration not identical
  805.    A global procedure, function or variable declaration is incompatible
  806.    with a previous declaration of the same name.  This sometimes results
  807.    from nested procedures or local constants.
  808.  
  809. .p a
  810. .v EXPLANATION OF ERRORS REPORTED BY THE C COMPILER
  811.  
  812. .c (SECTION TO BE WRITTEN)
  813.         
  814.  
  815. .p a
  816. .v REVISION HISTORY
  817.  
  818.   See HISTORY.DOC for the complete revision history.
  819.  
  820. 03/30/88 v1.7a
  821. 03/25/88 v1.7
  822.    Repackaged into three archives:  
  823.       TPTC17.ARC    (main file; exe, docs and supporting files)
  824.       TPTC17SC.ARC  (source code)
  825.       TPTC17TC.ARC  (test cases)
  826.  
  827. 02/13/88 v1.6
  828.    First distributed as TPTC16 under the SourceWare concept.
  829.  
  830. 06/01/87 v1.5
  831. 05/26/87 v1.4
  832. 05/20/87 v1.3
  833. 04/22/87 v1.2
  834. 04/15/87 v1.1
  835. 12/19/86 v1.0
  836.    First distributed as TPC10 under ShareWare concept.
  837.  
  838. 09/09/85 v0.0 
  839.    Initial coding by Samuel H. Smith.  Never released.
  840.  
  841.  
  842. .v SUPPORT
  843.  
  844. I work very hard to produce a software package of the highest quality
  845. and functionality.  I try to look into all reported bugs, and will
  846. generally fix reported problems within a few days.
  847.  
  848. Since this is user supported software under the SourceWare  concept, I
  849. don't expect you to contribute if you don't like it or if it doesn't
  850. meet your needs.
  851.  
  852. If you have any questions, bugs, or suggestions, please contact  me at:
  853.     The Tool Shop BBS
  854.     (602) 279-2673
  855.  
  856. The latest version is always available for downloading.
  857.  
  858.  
  859. I continue to update and improve TPTC.  If you have a program that TPTC
  860. will not translate, please send me a copy of it.  This will help me in
  861. future versions.  I will not redistribute the file without your
  862. permission.
  863.  
  864. Send sample sources to:
  865.     Samuel. H. Smith
  866.     (602) 279-2673 (data)
  867.     5119 N. 11 ave 332
  868.     Phoenix, Az 85013
  869.  
  870. .p a
  871. .v LICENSE
  872.  
  873. .u SourceWare: What is it?
  874.  
  875. SourceWare is my name for a unique concept in user supported software.
  876.  
  877. Programs distributed under the SourceWare concept always offer complete
  878. source code.
  879.  
  880. This package can be freely distributed so long as it is not modified or
  881. sold for profit.  If you find that this program is valuable,  you can
  882. send me a donation for what you think it is worth.  I suggest about $20.
  883.  
  884. Send your contributions to:
  885.    Samuel. H. Smith
  886.    5119 N. 11 ave 332
  887.    Phoenix, Az 85013
  888.  
  889.  
  890. .u Why SourceWare?
  891.  
  892. Why do I include source code?  The value of good software should be
  893. self-evident.  The source code is the key to complete understanding of a
  894. program.  You can read it to find out how things are done.  You can also
  895. change it to suit your needs, so long as you do not distribute the
  896. modified version without my consent.
  897.  
  898.  
  899. .u Copyright
  900.  
  901. If you modify this program, I would appreciate a copy of the new source
  902. code.   I am holding the copyright on the source code, so please don't
  903. delete my name from the program files or from the documentation.
  904.  
  905.